import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';
import { useI18n } from '@/hooks/web/useI18n';

//#region 打印报告数据源模式枚举
/** 打印报告数据源模式枚举 */
export enum PrintReportDsModeEnum {
  /** 推 */
  Push = 1,
  /** 拉 */
  Pull = 2,
}
//#endregion

/** 打印报告数据源模式实体 */
export class PrintReportDsModeEntity {
  /** 数据源模式 */
  DsMode: PrintReportDsModeEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(dsMode: PrintReportDsModeEnum, color?: PresetColorEnum | string) {
    const { t } = useI18n();
    this.DsMode = dsMode;
    this.Color = color;
    switch (dsMode) {
      case PrintReportDsModeEnum.Push:
        // this.Display = '推';
        this.Display = t('report.enum.printReportDsMode.push');
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case PrintReportDsModeEnum.Pull:
        // this.Display = '拉';
        this.Display = t('report.enum.printReportDsMode.pull');
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
    }
  }
}

//#region 打印报告数据源模式枚举架构
/**
 * 打印报告数据源模式枚举架构
 */
export function getPrintReportDsModeEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const entities: PrintReportDsModeEntity[] = [
    new PrintReportDsModeEntity(PrintReportDsModeEnum.Push),
    new PrintReportDsModeEntity(PrintReportDsModeEnum.Pull),
  ];
  entities.forEach((item) => {
    enumSchema.push({
      key: item.DsMode as number,
      label: item.Display,
      value: item.DsMode as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
